|
|
|
|
|
|
|
This procedure simply returns the background color of the user control and can be used as is. However, you need to add an extra line to the Property Let procedure, as shown here: |
|
|
|
|
|
|
|
|
Public Property Let BackColor(ByVal New_BackColor As OLE_COLOR)
UserControl.BackColor() = New_BackColor
lngBackColor = UserControl.BackColor
PropertyChanged "BackColor"
End Property |
|
|
|
|
|
|
|
|
In this code, notice that a line was added to store the color in the variable lngBackColor. This variable, declared in the General Declarations section, is used by code in the Paint event. The other properties, shown in Listing 14.6, are coded in a similar fashion. |
|
|
|
|
|
|
|
|
Listing 14.6 COLORBTN.ZIPMost of the Property Procedures Were Created by the Wizard |
|
|
|
|
|
|
|
|
Public Property Get Font() As Font
Set Font = UserControl.Font
End Property
Public Property Set Font(ByVal New_Font As Font)
Set UserControl.Font = New_Font
PropertyChanged "Font"
End Property
Public Property Get ForeColor() As OLE_COLOR
ForeColor = UserControl.ForeColor
End Property
Public Property Let ForeColor(ByVal New_ForeColor As OLE_COLOR)
UserControl.ForeColor() = New_ForeColor
lngForeColor = UserControl.ForeColor
PropertyChanged "ForeColor"
End Property
Public Property Get Caption() As Variant
Caption = m_Caption
End Property
Public Property Let Caption(ByVal New_Caption As Variant)
m_Caption = New_Caption
UserControl_Paint
PropertyChanged "Caption"
End Property |
|
|
|
|
|
|
|
|
Although you need to declare the variables lngForeColor and lngBackColor, the ActiveX Control Interface Wizard declares m_Caption for you automatically. The reason for this difference is that the Caption property is not mapped to the UserControl object. You also might want to set the constant for the default caption name, m_def_Caption, to something other than 0. ColorBtn would be an appropriate choice.  |
|
|
|
|
|
|
|
|
|
The wizard also creates the code for the WriteProperties and ReadProperties events so that the property values can be saved in the PropertyBag object. |
|
|
|
|
|
|
|